//index.js
//获取应用实例
const app = getApp()

Page({
    data: {
        imgUrls: [
          'http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg',
          'http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg',
          'http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg'
        ],
        indicatorDots: true,
        autoplay: true,
        interval: 5000,
        duration: 1000,
        list: [],
      },

      detailFn:function(e){
        const obj = e.currentTarget.dataset.obj;
        wx.navigateTo({
          url: '/pages/detail/detail?id=' + obj.id,
        })
      },

      indexList: function () {
        wx.request({
          url:'https://hq.stackwin.cn/v2/movie/top250?start=1&count=20',
          data: {
  
          },
          header: {
            'content-type': 'application/xml'
          },
          success:res => {
            const list = res.data.subjects;
            console.log(list)
            this.setData({
              list: list
             });
          },
  
          fail: error=> {
            console.log("调用接口失败！");
          }            
        })
      },  

    /**
   * 生命周期函数--监听页面加载
   */
    onLoad: function (options) {
      this.indexList();
    },

   
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {
    
    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
    
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {
    
    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {
    
    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {
    
    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {
    
    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {
    
    }
})
